package com.aiit.service.Impl;

import com.aiit.mapper.ResumeMapper;
import com.aiit.pojo.Resume;
import com.aiit.service.ResumeService;
import com.aiit.vo.PageResultVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: LuTao
 * @Date: 2022/05/09/11:01
 */
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper, Resume> implements ResumeService {
    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public PageResultVo<Resume> getByCondition(Long page, Long limit, String username) {
        PageResultVo<Resume> pageResultVo = new PageResultVo<>();
        pageResultVo.setRecords(resumeMapper.getByCondition((page-1)*limit,limit,username));
        pageResultVo.setTotal(resumeMapper.getCountByCondition(username));
        return pageResultVo;
    }

    @Override
    public Resume getByUserId(String id) {
        return baseMapper.selectOne(new QueryWrapper<Resume>()
                .eq("user_id",id)
                .last("limit 1"));
    }
}
